package mixins

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/mixin"
	"gitlab.zhijiasoft.com/paperless-group/saas-common/utils/key_secret"
)

type KeyMixin struct {
	mixin.Schema
}

func (KeyMixin) Fields() []ent.Field {
	return []ent.Field{
		field.String("key").SchemaType(map[string]string{
			dialect.MySQL: "char(32)",
		}).DefaultFunc(key_secret.GenKey).Comment("key"),
		field.String("secret").SchemaType(map[string]string{
			dialect.MySQL: "varchar(300)",
		}).Optional().DefaultFunc(key_secret.GenSecret).Comment("secret | 授权secret"),
	}
}
